Skip to content

Adds Builder and VM Manager interfaces + implementation for UVM#2597

Open
rawahars wants to merge 2 commits intomicrosoft:mainfrom
rawahars:feat/vm-package
Open

Adds Builder and VM Manager interfaces + implementation for UVM#2597
rawahars wants to merge 2 commits intomicrosoft:mainfrom
rawahars:feat/vm-package

Conversation

@rawahars
Copy link
Contributor

This pull request introduces a major refactor and formalization of the Utility VM (UVM) builder and management interfaces. It separates the responsibilities for VM configuration, host-side management, and guest-side actions into clear, testable layers. The changes include a new, well-documented builder interface, VM manager interface, concrete builder and VM manager implementations, along with comprehensive unit tests for the builder's functionality.

The most important changes are:

Architectural Refactor and Documentation

  • Added a detailed README.md to the internal/vm package, clearly explaining the separation of concerns between the Builder, VM Manager, and Guest Manager layers, and documenting the responsibilities and flow for each layer.

Builder Interface and Implementation

  • Replaced the old UVMBuilder interface with a new, comprehensive Builder interface in internal/vm/builder.go, providing modular access to memory, processor, NUMA, device, boot, and storage QoS configuration managers.
  • Introduced a concrete implementation of the Builder interface in internal/vm/builder/builder.go for creating and configuring hcsschema.ComputeSystem documents.

VM Manager Interface and Implementation

  • Created a new comprehensive UVM interface which corresponds to VM manager functionality.
  • All the VM host side modification are responsibility of this interface.

Testing

  • Added comprehensive unit tests for builder verification.

These changes establish a foundation for future VM configuration and management features.

Refactor the UVM code to clearly separate responsibilities across the VM
layers (builder vs. vmmanager) and document the intended architecture.

This reorganizes the former `internal/vm/hcs` package into focused
builder and manager packages and updates the core interfaces/types.

Key changes:
- Introduce `internal/vm/builder` as the concrete `Builder` implementation
  for constructing HCS compute system documents.
- Add `internal/vm/vmmanager` package for host-side UVM lifecycle and
  resource management; move HCS-backed managers here.
- Replace the old `UVMBuilder` with a `Builder` interface and manager
  sub-interfaces for memory/processor/numa/device/boot/storage QoS.
- Consolidate shared VM types and errors into `internal/vm/builder_types.go`
  (guest OS, memory backing, processor config, device IDs).
- Add the `internal/vm/README.md` describing the 3-layer VM model and
  typical usage flow.
- Move HCS-specific implementations into their new packages; delete
  obsolete `internal/vm/hcs` files and rename movers (boot/memory/network/etc.).
- Normalize builder APIs to be configuration setters (no errors where

Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
// ReadOnly indicates whether the scsi disk is read only or not.
ReadOnly bool
// ExtensibleVirtualDiskType is the disk type of the extensible virtual disk.
ExtensibleVirtualDiskType string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to only make sense when the type is EVD. Can we just have it be a sub type anyways?

return uvm
}

func (uvm *utilityVM) AddSCSIDisk(ctx context.Context, disk vm.SCSIDisk) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we dont just use hcsschema.Attachment here for the caller? Like what is the need of having the SCSIDisk type in the middle what do we gain? Its just yet more translations

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally, we had planned on making the calls to each of these methods generic. That way any other backends can act as VMM. But given that we are coupling it to specifically HCS, we can make this change.

LifetimeManager() LifetimeManager

// NetworkManager returns an interface for managing network adapters for the Utility VM.
NetworkManager() NetworkManager
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we said we werent going to do these and just have the static asserts so the caller can think of a VM as a NetworkManager great. But didnt need to indirect through this?

return uvm
}

func (uvm *utilityVM) AddVPMemDevice(ctx context.Context, id uint32, path string, readOnly bool, imageFormat string) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, to avoid more layers. Let the caller pass into the "syscall layer" the VirtualPMemDevice right? Like why have more translations

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think about it this way. If you add VPMemDeviceMode::SomeNewMode do you want to have to update this function? Or make an overload? I don't... I just want the caller that reads it from some spec to set that flag and the rest of the layers just enact it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants